<div class="span10">{{ widgets:area slug="{{ variables:DevThemeName }}-widget-area-comments" }}</div>
<?php if ($comments): ?>
<div class="row-fluid comments-container">
	<h3 class="span12"><?php echo lang('comments.title'); ?> 
    <span class="badge badge-info"><?php echo count($comments); ?></span> 
    &raquo; <a class="btn btn-info" data-toggle="modal" href="#ui-leave-comment" >
    <?php echo lang('comments.your_comment'); ?></a>
    
    </h3>
 
  
	<?php foreach ($comments as $item): ?>
 
    <article class="span5 comment-container {{theme:options:useTimeAgo}}">
    	<div class="row-fluid">
        <header class="span12">
        	<h5><?php echo gravatar($item->email, 40); ?>
              <?php if ($item->user_id): ?>
       					<?php echo anchor(
						$item->website ? $item->website : 'user/'.$item->user_id, 
						$this->ion_auth->get_user($item->user_id)->username, 
						$item->website ? 'rel="external nofollow"' : ''); ?>
					<?php else: ?>
                    	<?php echo $item->website ? anchor($item->website, 
						$item->name, 'rel="external nofollow"') : $item->name; ?>
					<?php endif; ?>
                    <?php echo anchor($item->website, 
		   '<i class="icon-globe icon-white"></i>', 'target="new" class="btn btn-small 
		   btn-inverse pull-right"' ) ?>
                    </h5>
        </header>
        </div>
              
              <div class="row-fluid">
              	<div class="span12 comment-inner">
                <?php if (Settings::get('comment_markdown') AND $item->parsed > ''): ?>
						<?php echo $item->parsed; ?>
					<?php else: ?>
						<?php echo nl2br($item->comment); ?>
					<?php endif; ?>
                </div>
              </div>
              
              
   	<footer class="row-fluid">
    	<time class="span12" datetime="<?php echo date('Y-m-d H:i:sP', $item->created_on); ?>">
		   <?php echo format_date($item->created_on); ?> &raquo; <?php echo date('H:i:s',$item->created_on); ?></time>
    </footer>
</article>

    <?php endforeach; ?> 
</div>     
<?php else: ?>
<div class="row-fluid  comments-container">
<h3 class="span12"><?php echo lang('comments.no_comments'); ?> 
    <span class="badge badge-info"><?php echo count($comments); ?></span> 
    &raquo; <a class="btn btn-info" data-toggle="modal" href="#ui-leave-comment" >
    <?php echo lang('comments.your_comment'); ?></a>
    </h3>
    </div>
<?php endif; ?> 



<div class="modal hide fade" id="ui-leave-comment">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
    <h3><?php echo lang('comments.your_comment'); ?></h3>
  </div>
    <?php echo form_open('comments/create/' . $module . '/' . $id, 
	'id="create-comment" class="form-horizontal"'); ?>
    

<div class="row-fluid">
	<div class="span12 ui-leave-comment-form">
    
    
    <?php echo form_hidden('redirect_to', uri_string()); ?>
			<noscript><?php echo form_input('d0ntf1llth1s1n', '', 'style="display:none"'); ?></noscript>
            
        <fieldset>
          
          
          <?php if ( ! $current_user): ?>

			<div class="form_name">
				<label for="name"><?php echo lang('comments.name_label'); ?>:</label>
				<input type="text" name="name" id="name" maxlength="40" value="<?php echo $comment['name'] ?>" />
			</div>

			<div class="form_email">
				<label for="email"><?php echo lang('comments.email_label'); ?>:</label>
				<input type="text" name="email" maxlength="40" value="<?php echo $comment['email'] ?>" />
			</div>

			<div class="form_url">
				<label for="website"><?php echo lang('comments.website_label'); ?>:</label>
				<input type="text" name="website" maxlength="40" value="<?php echo $comment['website'] ?>" />
			</div>
            
            
            <?php else: /* show hidden fields of user data for ajax reasons*/ ?>
            
            <div class="form_name">
				<input type="hidden" name="name" id="name" maxlength="40" 
                value="<?php echo $current_user->display_name; ?>" />
			</div>

			<div class="form_email">
				<input type="hidden" name="email" maxlength="40" 
                value="<?php echo $current_user->email; ?>" />
			</div>

			<div class="form_url">
				<input type="hidden" name="website" maxlength="40"
                value="<?php echo $current_user->website; ?>" />
			</div>
            
			<?php endif; ?>

			<div class="form_textarea">
				<label for="message"><?php echo lang('comments.message_label'); ?>:</label><br />
				<textarea style="margin:auto;" name="comment" id="message" 
                rows="8" cols="12" class="span8"><?php echo $comment['comment'] ?>
                </textarea>
			</div>

        </fieldset>
  
  <div class="modal-footer">
    <a href="#" class="btn" data-dismiss="modal">Close</a>
    <?php echo form_submit('submit', 
	lang('comments.send_label'), 'id="btn-comment" class="btn btn-primary"'); ?>
  </div>
  <?php echo form_close(); ?>
  		</div>
	</div>
</div>


